made some bug fixes I think