Bump version to 1.0.4-beta4. Code cleanup and update packages