Refactoring, updates, fixes