Fixed bug that caused data to sometimes become corrupted + other stability improvements.