Cleaned up code. Using more descriptive variable names. Using BitSet instead of StringBuilder and int[] to reduce memory footprint.