Some refactoring and important TODO's