Heavy refactoring of core

. Separate core and ui
. Make core more testable
. Usage of visitor pattern
. Provide a test generator to make large testCases