Complete refactor of lib!

Just look at the log.