Some cleanups, added documentation