Minor refactors, implemented missing function