Added basic thread support
Started work on error handing