Semi-complete frontend.

Several bugs remain to be fixed in the frontend, will be polished after
implementing functional frontend.