Partial refactoring, new method, fixes