adding a few more analysis options and cleaning up code