Add functions and bugfixes.