Several modifications, should work now