Add Mirego's fixes and improvements