Some fixes and refactoring