Added testing code, general cleanup