Restructuring some code

Changes made to some files...Errors still