Error fixing

Partially fixed code so that it works again. not finished