Bugfixes and better variable naming