Fixed function pointer issues, speed improvements, new unit tests