A lot of bugfixes and additions.