Refactor some libs, correct whitespace