Fixed compiler errors. Functionality not tested yet!