Code cleanup: remove logs, organize code, add clearer documentation.