Some code snippets, possibly helpful