Fixed numerous bugs in both server-side and client-side implementation