Merging some improvments back to master.