Split main code

Submitting a patch to main code as well as seperate code for models