updated a lot of the availability code
refactored so much code!
more improvements