Fixed some nasty bugs!