Release for testing, complete rewrite

Rewritten code for better efficiency