Add type spec, restructuralize module