Modified all System.arraycopy() to Array.clone(). Was getting NullPointerException.