Camera code refactor