Refactor camera code slightly