fixed tons of bugs for phase 1
submitted version for phase 1. many bugs fixed