renamed slots, added comments and rearranged functions