Implement object masks. Fixes #2