Fixed a few issues. Made timer functions interrupt safe