Fixed several bugs

http://bugzilla.seng.uvic.ca/show_bug.cgi?id=667
http://bugzilla.seng.uvic.ca/show_bug.cgi?id=277