Patches

Hi thanks for this! Found a few rough edges, looks to be working for me now.