Fixed memory leaks
Moved utility functions to separate file
Code formatting (tabs instead of spaces)
Prepared code for compilation on Windows systems (added library and defines)