some fixes to the code