Fixed small bugs and prealocate mat
Merge branch 'master' of github.com:YnkDK/ml14-project2