Cleaned up composite/component handling code, added tests