Refactored most of the code and added every functionality except for simulations.