Cleared debug console.logs and refactured a bit for speed and memory.

Signed-off-by: Mithron <mithron@gmail.com>