Added comments and renamed some functions according to Google R coding standard