Fixed mattias bugs