Re-arranged sql structure for Postgresql and modified amortization calculator api