Restructured code into a class!

Now usable in another project.
Expanable (NOTE: UNTESTED)