Update framework, fix various bugs