Starting to clean up code and fill in missing procedures.