various improvements, use classes