1. When you join, they'll make you sign an IP assignment form. This typically includes a section where you IP that you already owned before joining -- these will be excluded from assignment. Fill this section in extensively.
2. Make sure you work on your own stuff in your own time and with your own equipment.
3. Live in California -- the laws are much more on the employee's side on these issues.