Initial commit of first round of code

Not extensively tested yet but will be finalized soon