Reorganized source files and added documentation (docstrings)