added patches and some testing code snippets