Cleaned some bullshit and refactored the code.