Fixed Crashes

Added garbage collection, other small changes.