Code cleanup, error and success handling and updated docs