Fixing small bugs and improove the js dom attachment.