Fixed a bunch of inital bugs. 

not very descriptive, I know, but this update basically made the code usable.