todo's and minor refactoring