Refactor prototype into decent application.

Because the current prototype is not a decent application.