small fixes and code improvements