Fix semaphore initialization / error handling

Previous method of releasing semaphore could cause an issue on refresh
where available resources would be greater than the maximum allowed.
Also, added more robust fail-through in critical section.