Merge with krakjoe's work