Fixed some bugs jonathan introduced >_>