Bug fixes, some refactoring