Cleaned up code. Fixed bug stopping bot from shutting down correctly.