Improvements and fixes all around...

Still needs testing, so be careful.