Bunch of bugfixes and functionality added