various changes to engine fixed some bugs