Making function names clearer
Adding doc and simplifying function names
Further function simplification