Fixed compilation errors, maybe works?