Initial implementation, extracted from Gouda