tons of debugging and subsequent refactoring for improved stability