remove undocumented code and uncessary in_array() checks + cleanup