Fixed some annoying bugs