Further modified functions to be compatible with previous commit's changes. There are still memory corruption errors causing a segfault.