Finally got rid of lots of useless code