Refactor frames

Hi Alex and Shaun,

I've incorporated all the reviewed changes, could either of you please review and merge these changes?

Thanks

Shuang