Bugfixes, additions, still incomplete.