Port of Gibbed from C# to Java