Updated docstrings, and moved some imports to the top.