Removed redundant inOpen list and simplified code slightly.