Client-side re-structuring plus bugfixes