Merge "Fixes various bugs and adds some improvements"