Add comments and rename functions for consitency