Bugfixes and few additions

Check the commits.