OPEN/CLOSE function calls
many fixes, port to 3.5