more fixes and code readability