Fixed wrong argument usage and ClassCastException