Cleaned up rivergen code