Complete Java port of CSS extension code