added profiler, refactor codebase