Cleanup, improvements, fixes

Please check the commits for details. :)