bug and error fixes