There is heavy code duplication because I'm lazy, but loader needs to be refactored anyway at some point and this "works" for now.