From master: Bug fixes and improvements.