Clean up some code, fix issues with patch instead of put in links