Fix link error on MinGW
Add .gitignore
Refactor some ugly stuff

Note: This commit breaks VS 2012 compilation.
Update year