Fixed available() function calculation
Change *_available() functions to be more readable, fix function return types.