fixed missing files, further refactoring