Fixed the bugs that silus mentioned