First implementation based on Smack tutorial.