Added spacesAvailable

Also general fixes.