Added some function comments, combined some sequential requests into a single when clause