Some polishing and bugfixing