Still cleaning up, commenting and improving readibility...