Fixed imports and reorganized code
Fixed server-side events