Refactored away TLV encoding loops
Extracted resource classes to their own files