Style fixes

The patch is huge but the changes are minor: mainly indentation and style issues, removing of unnecessary `Lwt` wrapping, and adding a `mli`. Feel free to pick only the changes you are interested in.