extracted a class; fixed some warnings