Restructure, fix loader code