Rewrote almost all code
Revert "Rewrote almost all code"

This reverts commit c3c937078f7dffe7554127831c89ad7f0ce7d5bc.
Rewrote almost all code