some fixes to code