Implemented proper Dispose() pattern, fixes an issue discovered by Visual Studio Code Analysis