Added foreign keys on res table and fixed the avaibility method
Finals minor format edits