Fixed bug in prepare function, wrote more tests, cleaned up some junk, left some TODOs