Fixed #4 and fixed #2. Rewrite the grammar to follow w3c as much as possible.