fix common bugs and errors