Lots and lots of bug fixes =] forgot to commit for a long time