Fixed the availability function

Also cleaned up some function headers