Documentation

Added comments explaining what's going on at each function/method call.