merged in latest upstream and fixed a few small issues