remove functions from public api, refactor error checks, optimze some functions for fun and speed