Code cleanup & documentation