fixes from other pull requests + my fixes for them

Almost ready for a release, just requires new version in .pm and date in Changes