New implementation of Smaug. Not final version