Fix class loading and resource handling issues