fixed some big bugs