Main code upload

This is a functioning version of the code. Not tested yet. Updates soon