camera fix and some refactoring