merged changes from deepthought. need to test complete app.