Fix some major issues. Not tested yet