various improvements and bug fixes
resolved merge conflicts