Updated with comments, name changes and well defined procedures.