Add port as argument
Add types and tables, add max amount and simplify error handling