Add useful functions + bugfixes