fixed some bugs etc