Added garbage collection to prevent memory leaks
Renamed NO_ERROR because it override windows API constant
Refactored and fix compiler warnings