diff --git a/Makefile b/Makefile
index a586c528e4c39e983195ddbab306f761767fbe9d..78a83d1d0cd0ef913a077d966584085efd619b72 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,7 @@ include sockitowm/sockitowm.mk
 include dev/dev.mk
 
 
-CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) \
+CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) -Wall \
 	-ffunction-sections -fdata-sections -Os \
 	-include include/trace.h
 
diff --git a/dev/eeprom.c b/dev/eeprom.c
index 3cb9be2d26bee204970ed353c6672c6d59d2118a..2d35a72724e2a7715a010a9dfe0c683c9d11a406 100644
--- a/dev/eeprom.c
+++ b/dev/eeprom.c
@@ -1,3 +1,6 @@
+#include <string.h>
+#include <wrc.h>
+
 #include "types.h"
 #include "i2c.h"
 #include "eeprom.h"
@@ -163,7 +166,7 @@ int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
 			chksum =
 			    (uint8_t) ((uint16_t) chksum + *(ptr++)) & 0xff;
 		if (chksum != sfp->chksum)
-			EE_RET_CORRPT;
+			return EE_RET_CORRPT;
 	} else {
 		/*count checksum */
 		ptr = (uint8_t *) sfp;
@@ -271,7 +274,7 @@ int8_t eeprom_init_purge(uint8_t i2cif, uint8_t i2c_addr)
 int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
 {
 	uint8_t i = 1;
-	char separator = ' ';
+	uint8_t separator = ' ';
 	uint16_t used, readback;
 
 	if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT, (uint8_t *) & used,
@@ -314,7 +317,7 @@ int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
 int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
 {
 	uint16_t used, i;
-	char byte;
+	uint8_t byte;
 
 	if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT, (uint8_t *) & used,
 	     sizeof(used)) != sizeof(used))
@@ -335,7 +338,7 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
 	return 0;
 }
 
-int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, char *buf,
+int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf,
 			   uint8_t bufsize, uint8_t next)
 {
 	static uint16_t ptr;
diff --git a/dev/endpoint.c b/dev/endpoint.c
index a11a9296b8c461c865e78cd4ba98e221d07db515..0f7eddd48b98b8add303ceea632329faaeaa2778 100644
--- a/dev/endpoint.c
+++ b/dev/endpoint.c
@@ -9,6 +9,7 @@ LGPL 2.1
 */
 
 #include <stdio.h>
+#include <wrc.h>
 
 #include "board.h"
 #include "syscon.h"
diff --git a/dev/ep_pfilter.c b/dev/ep_pfilter.c
index 7089031e0456a274d869568d1e45a5fd06f5c501..768f438ad013157dfe65af5675f391153d42c0b1 100644
--- a/dev/ep_pfilter.c
+++ b/dev/ep_pfilter.c
@@ -76,7 +76,7 @@
 
 #define PFILTER_MAX_CODE_SIZE      32
 
-#define pfilter_dbg
+#define pfilter_dbg(x, ...) /* nothing */
 
 extern volatile struct EP_WB *EP;
 
@@ -87,7 +87,7 @@ static int code_pos;
 static uint64_t code_buf[32];
 
 /* begins assembling a new packet filter program */
-void pfilter_new()
+static void pfilter_new()
 {
 	code_pos = 0;
 }
@@ -108,7 +108,8 @@ static void check_reg_range(int val, int minval, int maxval, char *name)
 	}
 }
 
-void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd)
+static void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op,
+			int rd)
 {
 	uint64_t ir;
 
@@ -132,28 +133,7 @@ void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd)
 	code_buf[code_pos++] = ir;
 }
 
-   // rd                    = (packet[offset] & (1<<bit_index)) op rd
-void pfilter_btst(int offset, int bit_index, pfilter_op_t op, int rd)
-{
-	uint64_t ir;
-
-	check_size();
-
-	if (offset > code_pos)
-		pfilter_dbg
-		    ("microcode: comparison offset is bigger than current PC. Insert some nops before comparing");
-
-	check_reg_range(rd, 1, 15, "ra/rd");
-	check_reg_range(bit_index, 0, 15, "bit index");
-
-	ir = ((1ULL << 33) | PF_MODE_CMP | ((uint64_t) offset << 7) |
-	      ((uint64_t) bit_index << 29) | (uint64_t) op | ((uint64_t) rd <<
-							      3));
-
-	code_buf[code_pos++] = ir;
-}
-
-void pfilter_nop()
+static void pfilter_nop()
 {
 	uint64_t ir;
 	check_size();
@@ -162,7 +142,7 @@ void pfilter_nop()
 }
 
   // rd  = ra op rb
-void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb)
+static void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb)
 {
 	uint64_t ir;
 	check_size();
@@ -194,7 +174,7 @@ static void pfilter_logic3(int rd, int ra, pfilter_op_t op, int rb,
 }
 
 /* Terminates the microcode, loads it to the endpoint and enables the pfilter */
-void pfilter_load()
+static void pfilter_load()
 {
 	int i;
 	code_buf[code_pos++] = (1ULL << 35);	// insert FIN instruction
diff --git a/dev/minic.c b/dev/minic.c
index 6ff8852c8c28b134431c7cea4e2ea3310d4fa5d1..141a24fee6f524590653ff2ee8ae1b2ff4c8708b 100644
--- a/dev/minic.c
+++ b/dev/minic.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <string.h>
+#include <wrc.h>
 
 #include "types.h"
 #include "board.h"
@@ -186,7 +187,7 @@ int minic_rx_frame(uint8_t * hdr, uint8_t * payload, uint32_t buf_size,
 	uint32_t payload_size, num_words;
 	uint32_t desc_hdr;
 	uint32_t raw_ts;
-	uint32_t rx_addr_cur, cur_avail;
+	uint32_t cur_avail;
 	int n_recvd;
 
 	if (!(minic_readl(MINIC_REG_EIC_ISR) & MINIC_EIC_ISR_RX))
diff --git a/dev/onewire.c b/dev/onewire.c
index fa72f584aa8114dd7e8cb8350276e07f91436a7c..15827751456b7efc9f7b3d4f1c0b31ba19ce57c5 100644
--- a/dev/onewire.c
+++ b/dev/onewire.c
@@ -1,6 +1,10 @@
+#include <string.h>
+#include <wrc.h>
 #include "onewire.h"
 #include "../sockitowm/ownet.h"
 #include "../sockitowm/findtype.h"
+#include "../sockitowm/eep43.h"
+#include "../sockitowm/temp28.h"
 
 #define DEBUG_PMAC 0
 
@@ -72,7 +76,7 @@ int8_t get_persistent_mac(uint8_t portnum, uint8_t * mac)
 		if (FamilySN[i][0] == 0x43) {
 			owLevel(portnum, MODE_NORMAL);
 			if (ReadMem43(portnum, FamilySN[i], EEPROM_MAC_PAGE,
-				      &read_buffer) == TRUE) {
+				      read_buffer) == TRUE) {
 				if (read_buffer[0] == 0 && read_buffer[1] == 0
 				    && read_buffer[2] == 0) {
 					/* Skip the EEPROM since it has not been programmed! */
@@ -116,7 +120,7 @@ int8_t set_persistent_mac(uint8_t portnum, uint8_t * mac)
 
 	/* Write the last EEPROM with the MAC */
 	owLevel(portnum, MODE_NORMAL);
-	if (Write43(portnum, FamilySN[0], EEPROM_MAC_PAGE, &write_buffer) ==
+	if (Write43(portnum, FamilySN[0], EEPROM_MAC_PAGE, write_buffer) ==
 	    TRUE)
 		return 0;
 
diff --git a/dev/pps_gen.c b/dev/pps_gen.c
index 3c559ab389fe7260682e4ce60e9476214630d005..12b28ccc9a33bcdbc471e1cb4694f387a1dc2ab0 100644
--- a/dev/pps_gen.c
+++ b/dev/pps_gen.c
@@ -1,3 +1,4 @@
+#include <wrc.h>
 #include "board.h"
 #include "pps_gen.h"
 
@@ -18,7 +19,7 @@
 #define ppsg_read(reg) \
 	*(volatile uint32_t *) (BASE_PPS_GEN + (offsetof(struct PPSG_WB, reg)))
 
-int pps_gen_init()
+void pps_gen_init()
 {
 	uint32_t cr;
 
@@ -38,8 +39,6 @@ int pps_gen_init()
 /* Adjusts the nanosecond (refclk cycle) counter by atomically adding (how_much) cycles. */
 int pps_gen_adjust(int counter, int64_t how_much)
 {
-	uint32_t cr;
-
 	TRACE_DEV("Adjust: counter = %s [%c%d]\n",
 		  counter == PPSG_ADJUST_SEC ? "seconds" : "nanoseconds",
 		  how_much < 0 ? '-' : '+', (int32_t) abs(how_much));
@@ -61,10 +60,8 @@ int pps_gen_adjust(int counter, int64_t how_much)
 }
 
 /* Sets the current time */
-int pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
+void pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
 {
-	uint32_t cr;
-
 	ppsg_write(ADJ_UTCLO, (uint32_t) (seconds & 0xffffffffLL));
 	ppsg_write(ADJ_UTCHI, (uint32_t) (seconds >> 32) & 0xff);
 	ppsg_write(ADJ_NSEC,
@@ -72,7 +69,6 @@ int pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
 			      (int64_t) REF_CLOCK_PERIOD_PS));
 
 	ppsg_write(CR, (ppsg_read(CR) & 0xfffffffb) | PPSG_CR_CNT_SET);
-	return 0;
 }
 
 uint64_t pps_get_utc(void)
diff --git a/dev/sdb.c b/dev/sdb.c
index fcfad4de2a986ca3264d00dea30015ab2b5a77c7..eafb5593d3d7374c1b630c03aa7008dbd0d14ea9 100644
--- a/dev/sdb.c
+++ b/dev/sdb.c
@@ -1,3 +1,5 @@
+#include <string.h>
+#include <wrc.h>
 #include "hw/memlayout.h"
 
 #define SDB_INTERCONNET 0x00
@@ -117,7 +119,7 @@ static void print_devices_deep(unsigned int base, unsigned int sdb)
 
 static unsigned char *find_device(unsigned int devid)
 {
-	find_device_deep(0, SDB_ADDRESS, devid);
+	return find_device_deep(0, SDB_ADDRESS, devid);
 }
 
 void sdb_print_devices(void)
diff --git a/include/eeprom.h b/include/eeprom.h
index 24df3e595cbd4a1bad63e01f8e526dd72cbf9ba2..bc18eb76b9b620df5215571d557cb185d8d6b74d 100644
--- a/include/eeprom.h
+++ b/include/eeprom.h
@@ -44,7 +44,11 @@ int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val,
 int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr);
 int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[]);
 int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr);
-int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, char *buf,
+int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf,
 			   uint8_t bufsize, uint8_t next);
 
+int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
+                       uint8_t add, uint8_t pos);
+int8_t eeprom_init_purge(uint8_t i2cif, uint8_t i2c_addr);
+
 #endif
diff --git a/include/endpoint.h b/include/endpoint.h
index e6866975a684211afcfe078b30fe352b733811de..1602fa36b2232276ab4ec1d487497e88904af348 100644
--- a/include/endpoint.h
+++ b/include/endpoint.h
@@ -27,14 +27,6 @@ int ep_get_psval(int32_t * psval);
 int ep_cal_pattern_enable();
 int ep_cal_pattern_disable();
 
-void pfilter_new();
-void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd);
-void pfilter_btst(int offset, int bit_index, pfilter_op_t op, int rd);
-void pfilter_nop();
-void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb);
-static void pfilter_logic3(int rd, int ra, pfilter_op_t op, int rb,
-			   pfilter_op_t op2, int rc);
-void pfilter_load();
 void pfilter_init_default();
 
 uint16_t pcs_read(int location);
diff --git a/include/pps_gen.h b/include/pps_gen.h
index 98155cdd8428f22882b57dfe6a1583c811bdb1c5..8dc7a636e6294d423310ce62c29e178e10ea073f 100644
--- a/include/pps_gen.h
+++ b/include/pps_gen.h
@@ -7,21 +7,21 @@
 #define PPSG_ADJUST_NSEC 0x2
 
 /* Initializes the PPS Generator. 0 on success, negative on failure. */
-int shw_pps_gen_init();
+void pps_gen_init(void);
 
 /* Adjusts the <counter> (PPSG_ADJUST_SEC/NSEC) by (how_much) seconds/nanoseconds */
-int shw_pps_gen_adjust(int counter, int64_t how_much);
+int pps_gen_adjust(int counter, int64_t how_much);
 
 /* Returns 1 when the PPS is busy adjusting its time counters, 0 if PPS gen idle */
-int shw_pps_gen_busy();
+int pps_gen_busy(void);
 
 /* Enables/disables PPS Generator PPS output */
-int shw_pps_gen_enable_output(int enable);
+int pps_gen_enable_output(int enable);
 
 /* Reads the current time and stores at <seconds,nanoseconds>. */
-void shw_pps_gen_get_time(uint64_t * seconds, uint32_t * nanoseconds);
+void pps_gen_get_time(uint64_t * seconds, uint32_t * nanoseconds);
 
 /* Sets the time to <seconds,nanoseconds>. */
-void shw_pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds);
+void pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds);
 
 #endif
diff --git a/include/sockitowm.h b/include/sockitowm.h
new file mode 100644
index 0000000000000000000000000000000000000000..981ca67096368b293bf9d5a301d8867aefba6347
--- /dev/null
+++ b/include/sockitowm.h
@@ -0,0 +1,6 @@
+#ifndef __SOCKITOWM_H__
+#define __SOCKITOWM_H__
+
+#include "sockitowm/ownet.h"
+
+#endif /* __SOCKITOWM_H__ */
diff --git a/include/uart.h b/include/uart.h
index 58aa4e99ed47ccc07322570dc6d8231518fb2fe7..5d0ae9ee2136b7e72b085ebc1e40e93c9155a557 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -1,10 +1,9 @@
 #ifndef __UART_H
 #define __UART_H
 
-int mprintf(char const *format, ...);
-
-void uart_init();
+void uart_init(void);
 void uart_write_byte(int b);
 void uart_write_string(char *s);
+int uart_read_byte(void);
 
 #endif
diff --git a/include/wrc.h b/include/wrc.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e5ec4e11326a10f16a5d4effda9531c0b2ce48c
--- /dev/null
+++ b/include/wrc.h
@@ -0,0 +1,27 @@
+#ifndef __WRC_H__
+#define __WRC_H__
+
+/*
+ * This header includes all generic prototypes that were missing
+ * in earlier implementations. For example, the monitor is only
+ * one function and doesn't deserve an header of its own.
+ * Also, this brings in very common and needed headers
+ */
+int mprintf(char const *format, ...)
+	__attribute__((format(printf,1,2)));
+
+void wrc_mon_gui(void);
+void shell_init(void);
+int wrc_log_stats(uint8_t onetime);
+
+
+/* This is in the library, somewhere */
+extern int abs(int val);
+
+/* The following from ptp-noposix */
+extern void wr_servo_reset(void);
+void update_rx_queues(void);
+void spll_enable_ptracker(int ref_channel, int enable);
+
+
+#endif /* __WRC_H__ */
diff --git a/lib/arp.c b/lib/arp.c
index b189273bd4eaabbdb388c188d0c99042f8d370aa..daf758719c16ce846d88c39686c71d0b790ce7c4 100644
--- a/lib/arp.c
+++ b/lib/arp.c
@@ -1,4 +1,5 @@
 #include <string.h>
+#include "endpoint.h"
 
 #include "ipv4.h"
 #include "ptpd_netif.h"
diff --git a/lib/bootp.c b/lib/bootp.c
index cdf3385f09199a6b9d7a49beafa15405a616805c..2f2f57b2197181a845a89087047b69f31159f4f2 100644
--- a/lib/bootp.c
+++ b/lib/bootp.c
@@ -1,4 +1,6 @@
 #include <string.h>
+#include <wrc.h>
+#include "endpoint.h"
 
 #include "ipv4.h"
 
diff --git a/lib/util.c b/lib/util.c
index d237634ef3a4556ec672b31ec59a38ce89490437..85d02de1e80f4c2604468944cae1244adbcefacd 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -2,6 +2,7 @@
 #include <stdint.h>
 #include <stdarg.h>
 #include <time.h>
+#include <wrc.h>
 
 #include "util.h"
 
diff --git a/monitor/monitor.c b/monitor/monitor.c
index bc60f091a973f152e0bc6122e6290fb4c00153c3..f62a4adcc106d58bb80c20c8abcdddf46f426ece 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -1,10 +1,12 @@
 #include <stdio.h>
 #include <time.h>
+#include <wrc.h>
 
 #include "board.h"
 #include "ptpd_exports.h"
 #include "hal_exports.h"
 #include "softpll_ng.h"
+#include "minic.h"
 #include "pps_gen.h"
 #include "util.h"
 #include "timer.h"
@@ -15,12 +17,8 @@
 extern ptpdexp_sync_state_t cur_servo_state;
 extern int wrc_man_phase;
 
-int wrc_mon_gui(void)
+void wrc_mon_gui(void)
 {
-	static char *slave_states[] = {
-		"Uninitialized", "SYNC_SEC", "SYNC_NSEC", "SYNC_PHASE",
-		"TRACK_PHASE"
-	};
 	static uint32_t last = 0;
 	hexp_port_state_t ps;
 	int tx, rx;
@@ -29,7 +27,7 @@ int wrc_mon_gui(void)
 	uint32_t nsec;
 
 	if (timer_get_tics() - last < UI_REFRESH_PERIOD)
-		return 0;
+		return;
 
 	last = timer_get_tics();
 
@@ -150,15 +148,11 @@ int wrc_mon_gui(void)
 
 	cprintf(C_GREY, "--");
 
-	return 0;
+	return;
 }
 
 int wrc_log_stats(uint8_t onetime)
 {
-	static char *slave_states[] = {
-		"Uninitialized", "SYNC_SEC", "SYNC_NSEC", "SYNC_PHASE",
-		"TRACK_PHASE"
-	};
 	static uint32_t last = 0;
 	hexp_port_state_t ps;
 	int tx, rx;
diff --git a/shell/cmd_calib.c b/shell/cmd_calib.c
index a2e23938490131670344e88dd639f42a74e35a24..5476ae3859eaed5bfeb082c0e5e90dc829768841 100644
--- a/shell/cmd_calib.c
+++ b/shell/cmd_calib.c
@@ -3,11 +3,13 @@
 
 		Description: launches the WR Core monitor GUI */
 
+#include <string.h>
+#include <wrc.h>
 #include "shell.h"
 #include "eeprom.h"
 #include "syscon.h"
 
-extern int measure_t24p(int *value);
+extern int measure_t24p(uint32_t *value);
 
 int cmd_calib(const char *args[])
 {
diff --git a/shell/cmd_init.c b/shell/cmd_init.c
index 62c62b3bfb43a6534271d2191ee2ba8ed73644a5..773c63e8c3bd0775316acce7f3804ee5054b9207 100644
--- a/shell/cmd_init.c
+++ b/shell/cmd_init.c
@@ -1,7 +1,10 @@
 
+#include <string.h>
+#include <wrc.h>
 #include "shell.h"
 #include "eeprom.h"
 #include "syscon.h"
+#include "i2c.h"
 
 int cmd_init(const char *args[])
 {
diff --git a/shell/cmd_ip.c b/shell/cmd_ip.c
index 15dbacb8cc28756fbf51fdb57f1661ac8e7011b5..d1b838b31523624fd8681efc3d80eb2bc9aade40 100644
--- a/shell/cmd_ip.c
+++ b/shell/cmd_ip.c
@@ -1,12 +1,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <wrc.h>
 
 #include "softpll_ng.h"
 #include "shell.h"
 #include "../lib/ipv4.h"
 
-static decode_ip(const char *str, unsigned char *ip)
+static void decode_ip(const char *str, unsigned char *ip)
 {
 	int i, x;
 
@@ -38,4 +39,5 @@ int cmd_ip(const char *args[])
 		mprintf("IP-address: %d.%d.%d.%d\n",
 			ip[0], ip[1], ip[2], ip[3]);
 	}
+	return 0;
 }
diff --git a/shell/cmd_mac.c b/shell/cmd_mac.c
index 8c946bfad38844380bfd9e483c99615dde6b2ae7..29386dc8eb3c6d167a9f0d4db247a5764bb6251e 100644
--- a/shell/cmd_mac.c
+++ b/shell/cmd_mac.c
@@ -1,13 +1,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <wrc.h>
 
 #include "softpll_ng.h"
 #include "shell.h"
 #include "onewire.h"
+#include "endpoint.h"
 #include "../lib/ipv4.h"
 
-static decode_mac(const char *str, unsigned char *mac)
+static void decode_mac(const char *str, unsigned char *mac)
 {
 	int i, x;
 
@@ -44,4 +46,5 @@ int cmd_mac(const char *args[])
 
 	mprintf("MAC-address: %x:%x:%x:%x:%x:%x\n",
 		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+	return 0;
 }
diff --git a/shell/cmd_mode.c b/shell/cmd_mode.c
index 7aa8fc3160a921509154390640d879eae0c2ebe1..86449fe2745d719fafee9afa581d1f7e768f2c3c 100644
--- a/shell/cmd_mode.c
+++ b/shell/cmd_mode.c
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <wrc.h>
 
 #include "shell.h"
 #include "wrc_ptp.h"
diff --git a/shell/cmd_pll.c b/shell/cmd_pll.c
index abbe0ed47b2d67e5e740e953bf1a14a866c049a0..7c7595b68e400e6f5a9447f06fe1061cca9e9e63 100644
--- a/shell/cmd_pll.c
+++ b/shell/cmd_pll.c
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <wrc.h>
 
 #include "softpll_ng.h"
 #include "shell.h"
diff --git a/shell/cmd_ptp.c b/shell/cmd_ptp.c
index 23dd1678632971f5968a55af15d9c571d57f588d..7b9297c973ca6691a781bbdc79b3308ca2771064 100644
--- a/shell/cmd_ptp.c
+++ b/shell/cmd_ptp.c
@@ -5,7 +5,7 @@
 
 #include <errno.h>
 #include <string.h>
-
+#include "wrc_ptp.h"
 #include "shell.h"
 
 int cmd_ptp(const char *args[])
diff --git a/shell/cmd_sfp.c b/shell/cmd_sfp.c
index 9e1ed3b400785b136a93ba03a6c6f9c48472ae48..8ab415788ec2732843da03d45ad8524a6858277a 100644
--- a/shell/cmd_sfp.c
+++ b/shell/cmd_sfp.c
@@ -11,6 +11,10 @@
 			detect - detects the transceiver type
 */
 
+#include <string.h>
+#include <stdlib.h>
+#include <wrc.h>
+
 #include "shell.h"
 #include "eeprom.h"
 #include "syscon.h"
diff --git a/shell/cmd_stat.c b/shell/cmd_stat.c
index e4f0e4dd4c1421b697344c09a1fb6bc0f5e7c24d..8c6ea224490e130c090b51612afb05edeb7d5454 100644
--- a/shell/cmd_stat.c
+++ b/shell/cmd_stat.c
@@ -1,4 +1,6 @@
 #include "shell.h"
+#include <string.h>
+#include <wrc.h>
 
 int cmd_stat(const char *args[])
 {
diff --git a/shell/cmd_time.c b/shell/cmd_time.c
index 420a9ca6af51fb00c2bc95d2be61ebf8a2f52da6..053897a7673fb11b62cdf58e5e1af95f00ec60fa 100644
--- a/shell/cmd_time.c
+++ b/shell/cmd_time.c
@@ -8,6 +8,8 @@
 
 #include <errno.h>
 #include <string.h>
+#include <stdlib.h>
+#include <wrc.h>
 
 #include "shell.h"
 #include "util.h"
diff --git a/shell/cmd_version.c b/shell/cmd_version.c
index e89880154ea0c22d4686a766a31864acf26ad26f..700f231b94b411a4ecd3ea9e06bbea0a3709cd48 100644
--- a/shell/cmd_version.c
+++ b/shell/cmd_version.c
@@ -1,6 +1,8 @@
+#include <wrc.h>
 #include "shell.h"
 #include "syscon.h"
 
+
 extern const char *build_revision, *build_date;
 
 int cmd_version(const char *args[])
diff --git a/shell/environ.c b/shell/environ.c
index 6b5b30708b3c12023a5f750507fe22f534fe5d55..84ee09d0318c0e71749a7aa16f6195ebdd37fb34 100644
--- a/shell/environ.c
+++ b/shell/environ.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <wrc.h>
 
 #include "shell.h"
 
@@ -8,7 +9,7 @@
 
 /* Environment-related functions */
 
-static unsigned char env_buf[SH_ENVIRON_SIZE];
+static char env_buf[SH_ENVIRON_SIZE];
 
 void env_init()
 {
@@ -45,11 +46,12 @@ static int _env_end()
 	for (i = 0; i < SH_ENVIRON_SIZE; i++)
 		if (env_buf[i] == 0xff)
 			return i;
+	return 0;
 }
 
 int env_set(const char *var, const char *value)
 {
-	unsigned char *vstart = _env_get(var), *p;
+	char *vstart = _env_get(var), *p;
 	int end;
 
 	if (vstart) {		/* entry already present? remove current and append at the end of environment */
@@ -81,7 +83,7 @@ int env_set(const char *var, const char *value)
 
 int cmd_env(const char *args[])
 {
-	unsigned char *p = env_buf;
+	char *p = env_buf;
 
 	while (*p != 0xff) {
 		if (*p == 0xaa)
diff --git a/shell/shell.c b/shell/shell.c
index a62e77bfa58d922856e8cf50ed7b67e3ae19e406..2522603887757623c649ef82efe2a4d7be7e4238 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -2,6 +2,7 @@
 #include <string.h>
 #include <errno.h>
 
+#include <wrc.h>
 #include "util.h"
 #include "uart.h"
 #include "syscon.h"
@@ -275,7 +276,8 @@ int shell_boot_script(void)
 
 	while (1) {
 		cmd_len = eeprom_init_readcmd(WRPC_FMC_I2C, FMC_EEPROM_ADR,
-					      cmd_buf, SH_MAX_LINE_LEN, next);
+					      (uint8_t *)cmd_buf,
+					      SH_MAX_LINE_LEN, next);
 		if (cmd_len <= 0) {
 			if (next == 0)
 				mprintf("Empty init script...\n");
diff --git a/sockitowm/eep43.c b/sockitowm/eep43.c
index 4509b9c62f0ab83ad1ddd17479f31641d4f6fd8d..d0f386fc3ab34cd40d37f0ced2c326bf001eb7fc 100644
--- a/sockitowm/eep43.c
+++ b/sockitowm/eep43.c
@@ -1,3 +1,4 @@
+#include <wrc.h>
 #include "ownet.h"
 
 #define READ_SCRATCH_CMD 0xaa
@@ -8,6 +9,8 @@
 
 //#define DEBUG_EEP43 1
 
+static int Copy2Mem43(int portnum, uchar * SerialNum);
+
 int Write43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
 {
 	uchar rt = FALSE;
@@ -62,11 +65,9 @@ int Write43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
 	return rt;
 }
 
-int Copy2Mem43(int portnum, uchar * SerialNum)
+static int Copy2Mem43(int portnum, uchar * SerialNum)
 {
 	uchar rt = FALSE;
-	ushort lastcrc16;
-	int i;
 	uchar read_data;
 
 	owSerialNum(portnum, SerialNum, FALSE);
@@ -164,7 +165,6 @@ int ReadMem43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
 	uchar rt = FALSE;
 	ushort lastcrc16;
 	int i;
-	ushort target_addr = 0;
 	uchar read_data;
 
 	owSerialNum(portnum, SerialNum, FALSE);
diff --git a/sockitowm/owerr.c b/sockitowm/owerr.c
index f0fd5e1fda33d5637e70decc3738d918b9199b41..97e30ec7f50b7e22510b85fcf375461ecdd88f31 100644
--- a/sockitowm/owerr.c
+++ b/sockitowm/owerr.c
@@ -30,6 +30,7 @@
 //
 
 #include <string.h>
+#include <wrc.h>
 //#include <stdio.h>
 #include "ownet.h"
 #include "uart.h"
@@ -314,9 +315,6 @@ void owPrintErrorMsg(FILE * filenum)
 	char *f = owErrorStack[owErrorPointer].filename;
 	int err = owGetErrorNum();
 	//fprintf(filenum,"Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);
-#else
-	int err = owGetErrorNum();
-	//fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]);
 #endif
 }
 
diff --git a/sockitowm/ownet.h b/sockitowm/ownet.h
index d551f0e95186fd43c99d14b45497e79479409bb2..034357c83a94cb80816d261fb586c22f521d91c3 100644
--- a/sockitowm/ownet.h
+++ b/sockitowm/ownet.h
@@ -306,6 +306,8 @@ extern char *owGetErrorMsg(int);
 #define OWERROR_LIBUSB_SET_ALTINTERFACE_ERROR 123
 #define OWERROR_LIBUSB_NO_ADAPTER_FOUND 124
 
+SMALLINT owInit(void);
+
 // One Wire functions defined in ownetu.c
 SMALLINT owFirst(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
 SMALLINT owNext(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
diff --git a/tests/measure_t24p.c b/tests/measure_t24p.c
index 0d1b0e224f003546b684ce7d4fc22e0119539f00..99f8077c84bbedc82a1d26966fbad319abc6aa25 100644
--- a/tests/measure_t24p.c
+++ b/tests/measure_t24p.c
@@ -1,7 +1,8 @@
 #include <stdio.h>
 #include <inttypes.h>
-
 #include <stdarg.h>
+#include <wrc.h>
+
 #define INET_ADDRSTRLEN 16
 
 #include "syscon.h"
@@ -17,10 +18,12 @@
 
 #include "ptpd.h"
 
+#if 0 /* not used, currently */
 static int get_bitslide(int ep)
 {
 	return (pcs_read(16) >> 4) & 0x1f;
 }
+#endif
 
 struct meas_entry {
 	int delta_ns;
@@ -42,7 +45,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
 			    int phase_step, struct meas_entry *results)
 {
 	char buf[128];
-	wr_timestamp_t ts_tx, ts_rx, ts_sync;
+	wr_timestamp_t ts_rx, ts_sync = {0,};
 	wr_sockaddr_t from;
 	MsgHeader mhdr;
 	int setpoint = phase_min, i = 0, phase;
@@ -63,7 +66,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
 			msgUnpackHeader(buf, &mhdr);
 			if (mhdr.messageType == 0)
 				ts_sync = ts_rx;
-			else if (mhdr.messageType == 8) {
+			else if (mhdr.messageType == 8 && ts_sync.correct) {
 				MsgFollowUp fup;
 				msgUnpackFollowUp(buf, &fup);
 
@@ -84,6 +87,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
 				while (spll_shifter_busy(0)) ;
 				purge_socket(sock);
 
+				ts_sync.correct = 0;
 				i++;
 			}
 		}
@@ -100,6 +104,7 @@ static int find_transition(struct meas_entry *results, int n, int positive)
 		    && (results[(i + 1) % n].ahead == positive))
 			return i;
 	}
+	return -1;
 }
 
 extern void ptpd_netif_set_phase_transition(wr_socket_t * sock, int phase);
diff --git a/wrc_main.c b/wrc_main.c
index 478df98a7eee34a4308002412eb540a1006808d1..eafd773ce87ba83304bfafcc043240da6a1863d8 100644
--- a/wrc_main.c
+++ b/wrc_main.c
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 
+#include <wrc.h>
 #include "syscon.h"
 #include "uart.h"
 #include "endpoint.h"
@@ -14,6 +15,8 @@
 //#include "eeprom.h"
 #include "softpll_ng.h"
 #include "onewire.h"
+#include "pps_gen.h"
+#include "sockitowm.h"
 #include "shell.h"
 #include "lib/ipv4.h"
 
@@ -30,9 +33,7 @@ uint32_t cal_phase_transition = 2389;
 
 void wrc_initialize()
 {
-	int ret, i;
-	uint8_t mac_addr[6], ds18_id[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-	char sfp_pn[17];
+	uint8_t mac_addr[6];
 
 	sdb_find_devices();
 	uart_init();
@@ -117,8 +118,6 @@ void wrc_debug_printf(int subsys, const char *fmt, ...)
 	va_end(ap);
 }
 
-static int wrc_enable_tracking = 1;
-static int ptp_enabled = 1;
 int wrc_man_phase = 0;
 
 static void ui_update()
diff --git a/wrc_ptp.c b/wrc_ptp.c
index 421967aab9774c362a1a78b3e34ff136a49a8ba5..2e3f6e140657a9af8d552ae3da21c3b9c4baff32 100644
--- a/wrc_ptp.c
+++ b/wrc_ptp.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <inttypes.h>
 #include <errno.h>
+#include <wrc.h>
 
 #include "ptpd.h"
 #include "ptpd_netif.h"
@@ -8,6 +9,7 @@
 #include "softpll_ng.h"
 #include "wrc_ptp.h"
 #include "pps_gen.h"
+#include "uart.h"
 
 static RunTimeOpts rtOpts = {
 	.ifaceName = {"wr1"},