large refactor. commented all files