Bug fixes, added validation, renames and general cleanup