WIP refactoring, compiles and gets over 50percent accuracy now.