This is my own handiwork, bugs included.