updating manual, cleaning up code