Renamed some functions and improved internals.