fixed some various bugs