Removed some bugs found with bug tracker