refactored a bit
fixed filepointer bug that broke windows compatibility
Merge branch 'development'