Made plenty of small improvements and bug fixes