Style fixes and general cleanup. Also make example actually work in documentation.