Removed unused function, documented stuff, continuing separation of APIs and internal functions.