huge refactor, huge performance improvement.