some bug fixes over last commit