Move code to lib.rs and adjust crate_name

According to crates.io[1] this is best practice. Also no warnings/errors on this one with rust/cargo nightly

\[1\]: http://crates.io/manifest.html, "The Project Layout"

Oh, also some trailing-whitespace fixes. Hope that's okay