Major optimization (issue #4)

All the goals are achieved.