separated out api functions, re-wrote classes, made various methods