Added frontend code from Mada. Needs further review.